<?php

class IndexController extends Site_Controller_Action
{
    public function init()
    {
        
    }

    public function indexAction()
    {
        
        //$obj = new Admin_Model_DbTable_Textohome();
        //$result = $obj->fetchRow();
        //$this->view->texto = $result;
       
        $pagina = $this->_getParam('pagina', '');
        $this->view->pagina = $pagina;
        
        //$this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/validation/dist/jquery.validate.min.js');
        
        $fullbanner = $this->db->fetchAll('SELECT SQL_CACHE * FROM FULLBANNER WHERE BAN_STA = 1 ORDER BY BAN_ORD ASC');
        $this->view->fullbanner = $fullbanner;  
        
        
        $result = $this->db->fetchAll('SELECT SQL_CACHE * FROM PAGINA_SITE WHERE PGS_STA = 1 ORDER BY PGS_ORD ASC');
        $this->view->paginasite = $result;  
        
    }
    
    public function contatoAction()
    {
        $this->_helper->layout->disableLayout(); 
        $this->_helper->viewRenderer->setNoRender();
        
        $ok = false;
        
        if($this->getRequest()->isPost()) {
            try {
                $formData = $this->getRequest()->getPost();

                Zend_Loader::loadClass('envioemail','library');
                $arr['nome'] = $formData['nome'];
                $arr['empresa'] = $formData['empresa'];
                $arr['email'] = $formData['email'];
                $arr['telefone'] = $formData['telefone'];
                $arr['cidade'] = $formData['cidade'];
                $arr['mensagem'] = $formData['mensagem'];
                $arr['projeto'] = $formData['projeto'];
                $arr['urlbase']  = $this->_urlbase;
                $arr['modulo'] = '';//contato';
                $ok = envioemail::formularioContato($arr); 
                
            } catch (Exception $exc) {
                //echo 'error: '.$exc->getMessage(); 
            }
        }
        
        echo json_encode(array('ok' => $ok));
        
    }
    
}

